package com.jcgyl.export.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jcgyl.export.entity.PermissionsModel;
import com.jcgyl.export.entity.Tbsysmenu;
import com.jcgyl.export.service.PermissionsService;
import com.jcgyl.export.util.entity.Result;
//权限
@RestController
@RequestMapping("/roleAuthority")
public class PermissionsController {
	@Autowired
	private PermissionsService permissionsService;
	
	@PostMapping("/findAllPermissions")
	public List<String> doFindAllPermissions() {
		return permissionsService.findAllPermissions();
	}  
	@PostMapping("/findPermissionsByRId")
	public List<Integer>  doFindPermissionsByRId(@RequestBody String Id) {
		int rId =Integer.parseInt(Id);
		System.out.println(rId);
		return permissionsService.findPermissionsbyRId(rId);
	}  
	@PostMapping("/findZtreePermissions")
	public List<Tbsysmenu> doFindZtreePermissions() {
		return permissionsService.findZtreePermissions();
	} 
	@PostMapping("/updatePermissions")
	public Result doUpdatePermissions(@RequestBody PermissionsModel permissionsModel ) {
		int rid=permissionsModel.getId();
		List<Integer> list=permissionsModel.getList();
		System.out.println(list);
		return permissionsService.updatePermissionsbyRoleId(rid, list);
	} 
}
